package com.company;

import java.io.File;
import java.util.Scanner;

public class iotest02 {
    public static void main(String[] args){
        String dirpath=new Scanner(System.in).nextLine();
        File dir=new File(dirpath);
        long count= totasize(dir);
        System.out.println("文件夹路径是"+dirpath+",总大小是"+count);
        String[] str=dir.list();
        totasize(dir);

    }
   public static long totasize(File dir){
        long sum=0;
       File[] fs=dir.listFiles();
       for (int i=0;i<fs.length;i++){
           if (fs[i].isFile()){
               sum=sum+fs[i].length();
           }else if (fs[i].isDirectory()){
               sum=sum+totasize(fs[i]);
           }
       }
     return sum;
  }
}
